
package kaizone.haining.chaobohui.login;

import kaizone.haining.chaobohui.args.AppArgs;
import kaizone.haining.chaobohui.json.UserRegister;
import kaizone.haining.chaobohui.util.BDLocationWorker;

import android.content.Context;

import com.baidu.location.BDLocation;

public class User {

    public String userName = "user_2";

    public String userAuth = "56CE98A10DF20D17BF9ED9A6D0D1E4E8";

    private BDLocationWorker mLocationWorker;

    private double latitude;

    private double longitude;

    private String addrStr;

    public User(Context context) {
    	UserRegister register = AppArgs.readUserInfo(context);
    	userName = register.userName;
    	userAuth = register.authKey;
    }

    public User(Context context, BDLocationWorker locationWorker) {
    	this(context);
        mLocationWorker = locationWorker;
    }

    private void initLoaction() {

    }

    public boolean isLbs(){
    	return mLocationWorker.isEnable();
    }
    
    public BDLocation getLocation() {
        BDLocationWorker.log(mLocationWorker.getContext(), mLocationWorker.getLocation());
        return mLocationWorker.getLocation();
    }

    public double getLatitude() {
        if (mLocationWorker == null)
            return 0;
        if(!mLocationWorker.isEnable())
        	return 0;
        BDLocation location = getLocation();
        latitude = location.getLatitude();
        return latitude;
    }

    public double getLongitude() {
        if (mLocationWorker == null)
            return 0;
        if(!mLocationWorker.isEnable())
        	return 0;
        BDLocation location = getLocation();
        longitude = location.getLongitude();
        return longitude;
    }

    public String getAddrStr() {
        if(!mLocationWorker.isEnable())
        	return "";
        BDLocation location = getLocation();
        addrStr = location.getAddrStr();
        return addrStr;
    }

}
